package com.lzc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzc.pojo.entity.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {

    @Select("select * from (select * from messages where (source_id = #{sid} and target_id = #{rid}) or (source_id = #{rid} and target_id = #{sid}) order by send_time desc limit 8) f order by f.id asc")
    public List<Message> findHistoricalChat(@Param("sid") Long sid,@Param("rid") Long rid);
}
